package com.zzgele.qmzb.api.web;

import com.alibaba.boot.dubbo.annotation.DubboConsumer;
import com.github.pagehelper.PageInfo;
import com.zzgele.qmzb.api.core.Result;
import com.zzgele.qmzb.api.core.ResultGenerator;
import com.zzgele.qmzb.api.service.SongService;
import com.zzgele.qmzb.api.utils.PageUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

/**
 * create by jack
 */
@RequestMapping("/song")
@RestController
public class SongController {
    private final Logger logger = LoggerFactory.getLogger(SongController.class);
    @DubboConsumer
    private SongService songService;

    @PostMapping("/getSongList")
    public Result getSongList(String song, Integer classify_id, Integer hot, Integer page, Integer page_size) {
        PageUtil.startPage(page, page_size);
        HashMap map = new HashMap();
        map.put("song",song);
        map.put("classify_id", classify_id);
        map.put("hot", hot);//hot值为1，代表查询热门音乐
        List<HashMap> songList = songService.getList(map);
        HashMap songListHashMap = PageUtil.getPageInfoHashMap(new PageInfo(songList));

        return ResultGenerator.genSuccessResult(songListHashMap);
    }
}
